package edu.citadel.presentation.action;

import edu.citadel.presentation.context.Context;
import edu.citadel.utils.LoggingObject;
import net.sourceforge.stripes.action.ActionBean;
import net.sourceforge.stripes.action.ActionBeanContext;

import java.util.List;

/**
 * User: jordan
 * Date: 2/24/13
 * Time: 11:41 AM
 */
public class AbstractAction extends LoggingObject implements ActionBean {
    private Context context;

    @Override
    public void setContext(ActionBeanContext actionBeanContext) {
        context = (Context) actionBeanContext;
    }

    @Override
    public Context getContext() {
        return context;
    }


    public String formatErrorMessages(List<String> errors) {
        String html = "<div style='color:#b72222; font-weight: bold'>Please fix the following errors:</div><ol>";

        for (String error : errors) {
            html += "<li style='color: #b72222;'>" + error + "</li>";
        }

        html += "</ol>";

        return html;
    }

}
